1059A - Cashier - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

n, l, a = map(int, input().split())
x = 0
ans = 0
for _ in range(n):
    t, l0 = map(int, input().split())
    ans += (t - x) // a
    x = t + l0
ans += (l - x) // a
print(ans)

C++ Code:

#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main()
{
    int n,brdu,wd;
    cin >> n>>wd>>brdu;
    int rn=0,br=0;
    for(int i=0; i<n ;i++){
        int x, y;
        cin>> x>>y;
        int msh=x-rn;
        br+=msh/brdu;
        rn=x+y;

    }
    int msh=wd-rn;
    br+=msh/brdu;
    cout<<br<<endl;

    return 0;
}


Comments

Submit
0 Comments
More Questions

Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses